package drds.server.server.sqlcmd;

import drds.server.datasource.IConnectionHolder;
import drds.server.net.packet.ErrorPacket;
import drds.server.server.Session;

public class CommitCommand implements SQLCtrlCommand {

	@Override
	public void sendCommand(Session session, IConnectionHolder con) {
		con.commit();
	}

	@Override
	public void errorResponse(Session session, byte[] err, int total, int failed) {
		ErrorPacket errPkg = new ErrorPacket();
		errPkg.read(err);
		String errInfo = "total " + total + " failed " + failed + " detail:" + new String(errPkg.errorMessage);
		session.getSessionContext().setTransactionInterruptStatus(errInfo);
		errPkg.write(session.getSessionContext());
	}

	@Override
	public void okResponse(Session session, byte[] ok) {
		session.getSessionContext().write(ok);
	}

	@Override
	public boolean releaseConOnErr() {
		// need rollback when err
		return false;
	}

	@Override
	public boolean relaseConOnOK() {
		return true;
	}

	@Override
	public boolean isAutoClearSessionCons() {
		// need rollback when err
		return false;
	}

}
